package model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Model {

	private Meetstation meetstation = null;
	private Meting meting = null;
	private PropertyChangeSupport melder = null;
	private boolean connected = false;

	public Model() {
		melder = new PropertyChangeSupport(this);
	}

	public Meetstation getMeetstation() {
		return meetstation;
	}

	public void setMeetstation(Meetstation meetstation) {
		this.meetstation = meetstation;
		melder.firePropertyChange("station", "", meetstation);
	}

	public void setMeting(Meting m) {
		this.meting = m;
		melder.firePropertyChange("meting", "", meting);
	}

	public Meting getMeting() {
		return meting;
	}
	
	public boolean isConnected() {
		return connected;
	}
	
	public void setConnected( boolean c ) {
		boolean oldValue = connected;
		connected = c;
		melder.firePropertyChange("connection", oldValue, connected);
	}

	public void luisteraarToevoegen(String naam, PropertyChangeListener pL) {
		melder.addPropertyChangeListener(naam, pL);
	}
}
